package com.fujimana.rockincat.restree.context;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public abstract class BasicContext implements Context {

	private Map<String, Object> map;

	public BasicContext(Map<String, Object> map) {
		if (map == null) {
			map = new HashMap<String, Object>();
		}

		this.map = map;
	}

	@Override
	public Object get(String name) {
		return map.get(name);
	}

	@Override
	public Set<String> getKeys() {
		return map.keySet();
	}

	@Override
	public boolean isSet(String name) {
		return map.containsKey(name);
	}

	@Override
	public void remove(String name) {
		if (isSet(name)) {
			map.remove(name);
		}
	}

	@Override
	public void set(String name, Object value) {
		map.put(name, value);
	}

}
